package com.liner.homework.second;

public class Test {
    public static void main(String[] args) {

        Animal[] animals = new Animal[4];
        animals[0] = new Dog("柯基", 13, "橘色");
        animals[1] = new Fish("鲸鱼", 14, "蓝色");
        animals[2] = new Chick("小绿", 12, "绿色");
        animals[3] = new Dog("边牧", 12, "黑色");

        for (Animal animal : animals) {
            System.out.println(animal.name);
            animal.eat();
            animal.drink();

            if (animal instanceof Dog){
                ((Dog) animal).lookHome();
            }
            if (animal instanceof Chick){
                ((Chick) animal).layEggs();
            }
            if (animal instanceof Swim){
                ((Swim) animal).swim();
            }
        }

    }
}
